package com.sq.util.json;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

import com.sq.util.BeanUtil;
import com.sq.util.JsonUtil;
import com.sq.util.bean.Father;
import com.sq.util.bean.Son;
import com.sq.util.bean.TimeBean;

/**
 * @author sq
 *
 */
public class JsonDemo {
    public static void main(String[] args) throws Exception {
        Son s = new Son();
        s.setSonStr("sonStr");
        s.setFatherStr("fatherStr");
        Father f = (Father) s;

        System.out.println(f);
        System.out.println(f.getClass().getName());
        System.out.println(BeanUtil.trans(f, Father.class, true));
        System.out.println(JsonUtil.toJson(f));
        System.out.println(JsonUtil.toJson(f, Father.class));

        TimeBean t = new TimeBean();
        t.setDate(new Date());
        t.setLocalDate(LocalDate.now());
        t.setLocalDateTime(LocalDateTime.now());
        String json = JsonUtil.toJson(t);
        System.out.println(json);
        System.out.println(JsonUtil.toObject(json, TimeBean.class));

    }
}
